package com.twb.system.listener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import com.twb.system.service.ITwbDataDicService;
import com.twb.system.service.ITwbSysconfigService;
import com.twb.system.service.ITwbUserConfigService;

/** 
 * @ClassName TwbSystemRunner 
 * @Description 初始化字典、系统配置缓存数据
 * @author DSY
 * @date 2019年10月28日 下午9:02:22 
 */ 
@Component
public class TwbSystemRunner implements CommandLineRunner {

	@Autowired
	private ITwbDataDicService twbDataDicService;
	@Autowired
	private ITwbSysconfigService twbSysconfigService;
	@Autowired
	private ITwbUserConfigService twbUserConfigService;
	
	private final Logger logger = LoggerFactory.getLogger(TwbSystemRunner.class);
	@Override
	public void run(String... args) throws Exception {
		// TODO Auto-generated method stub
		try {
			twbDataDicService.initRedisDataDic();
			logger.debug("初始化字典数据成功");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			logger.debug("初始化字典数据失败");
		}
		
		try {
			twbSysconfigService.initRedisSysConfig();
			logger.debug("初始化系统配置数据成功");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			logger.debug("初始化系统配置数据失败");
		}
		
		try {
			twbUserConfigService.initRedisUserConfig();
			logger.debug("初始化用户配置数据成功");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			logger.debug("初始化用户配置数据失败");
		}
	}
}
